Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): prevent cookie-default behavior from mangling engine init #13331

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

jahorton
Copy link
Contributor

Fixes: #13278

The fallback default keyboard corresponding to an uninitialized cookie is Keyboard_us:en. This should only occur if the site actually registers its stub before initialization - and we weren't checking/filtering for this properly.

The error itself only occurred if there were stubs pre-registered before init - if none existed, the error does not result.

User Testing

TEST_WEB_PAGE_INIT: Using the KeymanWeb test page titled "Test OSK loading with early add-keyboard calls (#11785)", verify that the page initializes smoothly, without errors or alerts.

  • If an alert pops up saying "No matching stub has been registered", before you've interacted with any KMW elements, FAIL this test.

Fixes: #13278

The fallback default keyboard corresponding to an uninitialized cookie is `Keyboard_us:en`.   This should only occur if the site actually registers its stub before initialization - and we weren't checking/filtering for this properly.

The error itself only occurred if there _were_ stubs pre-registered before init - if none existed, the error does not result.
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Feb 24, 2025
@keymanapp-test-bot keymanapp-test-bot bot added this to the B18S2 milestone Feb 24, 2025
@jahorton jahorton linked an issue Feb 24, 2025 that may be closed by this pull request
// doAddKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
// filename:(prefix + 'us-1.0.js')});

// Do NOT link the us-1.0 keyboard here!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the difference between the original "commonHeader.js" and this specialized version - we do not want the us / Keyboard_us keyboard here, as its presence will greatly affect attempts to reproduce this PR's base issue.

@@ -820,11 +820,14 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
}

// Find the matching stub; if it doesn't exist, default to the first available stub.
let stub = this.keyboardCache.getStub(t[0], t[1]) || this.keyboardCache.defaultStub;
Copy link
Contributor Author

@jahorton jahorton Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this original line worked was at the core of the error we saw. If we had any default stub, that was enough to try activating the Keyboard_us keyboard if given the signal - regardless of whether or not it was present!

@dinakaranr
Copy link

Test Results

I tested this issue with the attached Keyman"18.0.197-beta-test-13331" build(24/02/2025) on the Web(KeymanWeb Test Page - Keyboard Quick-Load) page. Here I am sharing my observation.

  • TEST_WEB_PAGE_INIT (Passed):
  1. Launch the Chrome browser.
  2. Copy the "KeymanWeb Test Home" link.
  3. The page loaded with "KeymanWeb Test Page - Keyboard Quick-Load" appeared.
  4. Verified that no alert pops up and the page loaded smoothly without error.
  5. Click in the input text box.
  6. Verified that the OSK appeared.
    It works well. Thank you.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Feb 24, 2025
@jahorton jahorton merged commit 5db10ea into beta Feb 26, 2025
18 checks passed
@jahorton jahorton deleted the fix/web/init-should-not-cookie-default branch February 26, 2025 02:29
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.201-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

bug(web): poor cookie default can cause engine-init error
4 participants